Skip navigation

Tag Archives: shock

Today, we are going to expose some inner working of angular 2.

You know what, the double curly braces aka interpolation always  seems awesome magic.

<h1>{{ text }} </h1>

Really, this is sugar syntax for:

<h1 [innerText]=”text”></h1>

Yeah… angular 2 property binding using DOM attribute directly. So, is it possible to add class to a div tag?? Well

<h1 [className]=”active”></h1>

This is equivalent to

h1 = document.querySelector(‘h1’);
h1 = ‘active’;  // className is property of DOM element div

Interesting, isn’t it?


JavaScript keeps giving shock to me even after using, learning since so long years! I just came to know that hasOwnProperty method is not guarded by the JavaScript language. Users can override it. Below code demonstrates how to override, consequences and work around.

var foo = {
    // overriding foo's default hasOwnProperty method
    hasOwnProperty: function() {
        return false;
    bar: 'rajakvk'

foo.hasOwnProperty('bar'); // false always

// using hasOwnProperty of of object and setting this to foo
({}), 'bar'); // true

// or use hasOwnProperty from the 
// Object prototype for this purpose, 'bar'); // true

Learning experience with JavaScript is more excited day-by-day.

(function(undefined) {
    alert(typeof undefined);   // boolean
(function(undefined) {
    alert(typeof undefined);   // undefined

Refer jQuery source code (development version 1.7.1) and modernizr, the first line would be

(function( window, undefined ) {

})( window );
window.Modernizr = (function( window, document, undefined ) {

})(this, this.document);

To overcome the issue of undefined, these libraries passing undefined as local variable. Notice the third parameter is left blank.

Read my another post regarding the same topic.