Tip 1 was about concatenating code with different settings for strict. You can execute code in an anonymous function to minimize namespace pollution.


In [8]:
%%javascript

// isolating context for execution

(function () {
    
    "use strict";
    
    (function () {
        // 
        var arguments = [];
        element.text("hi")
    })();
    
})();



In [16]:
%%javascript

var k = {
    sProp: 'some string value',
    numProp: 2,
    bProp: false
};

element.text(k.sProp);



In [8]:
%%javascript

var myObj = {
     toString: function() {return "hello" },
     valueOf: function() {return 42}
};

// precedence of valueOf over toString

console.log("K" + myObj); // K42



In [ ]: