Last active
November 10, 2016 19:36
-
-
Save manojsinghnegiwd/4ed4e3776fd52483e7c6737e8f2af27c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function accessArguments () { | |
console.log(arguments[0]); | |
} | |
accessArguments(1, 2); // this will log 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var args = Array.prototype.slice.call(arguments); | |
args.slice(1, 2); // not you can use args as normal array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(1 == '1'); // this will log true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = (function IIFE(){ | |
return 'Hello I am IIFE'; | |
})(); | |
console.log(x) // will log Hello I am IIFE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = (function IIFE(){ | |
return arguments[0]; | |
})(1); | |
console.log(x) // will log 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = ['one', 'two', 'three', 'four', 'five', 'six']; | |
arr instanceof Array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(1 === '1'); // this will log false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function merge () { | |
var args = Array.prototype.slice.call(arguments); | |
var obj = {}; | |
for( var i = 0; i < args.length; i++ ) { | |
if(args[i] instanceof Object) { | |
for( var prop in args[i] ) { | |
obj[prop] = args[i][prop] // we append new object property and if any property exist overwrite it | |
} | |
} else { | |
console.error('you provided a non object at : ', i); | |
} | |
} | |
return obj; | |
} | |
var obj = merge( { x: 1 }, { y: 2 }, { x: 3 , y: 4} ) // will output {x: 3, y: 4} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function accessArguments () { | |
var x = arguments[1] || 2; | |
console.log(x); | |
} | |
accessArguments(1); // this will log 2 | |
accessArguments(1, 3); // this will log 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = 20; | |
var pass = x > 10 ? true : false | |
var Hurray = pass ? true : false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typeof x === 'undefined' // will return true | |
var x = 1; | |
typeof x === 'undefined' // will return false | |
typeof x === 'number' // will return true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment