Created
February 14, 2015 08:20
-
-
Save kshirish/9a1c5d615ebe85c87308 to your computer and use it in GitHub Desktop.
javascriptissexy
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
// immutable strings | |
var person = 'xyz'; | |
var anotherPerson = person; | |
person = 'abc'; | |
console.log(person); | |
console.log(anotherPerson); | |
// functions and other variables | |
var fun = function(){ | |
return 0; | |
} | |
var anotherFun = fun; | |
fun = function(){ | |
return 1; | |
} | |
fun(); | |
anotherFun(); | |
//referenced arrays and objects | |
var obj = { | |
name: 'john', | |
city: 'NY' | |
} | |
var anotherObj = obj; | |
obj.name = 'Doe'; | |
console.log(anotherObj); | |
console.log(obj); | |
var array = [1,2,4,5,8]; | |
var anotherArray = array; | |
array.pop(); | |
console.log(array); | |
console.log(anotherArray); | |
// delete | |
function fun() { | |
this.name = 'John'; | |
} | |
fun.prototype.age = 12; | |
var f = new fun(); | |
f.city = 'NY'; | |
delete f.name; | |
delete f.age; | |
delete f.city; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment