Skip to content

Instantly share code, notes, and snippets.

@kshirish
Created February 14, 2015 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kshirish/9a1c5d615ebe85c87308 to your computer and use it in GitHub Desktop.
Save kshirish/9a1c5d615ebe85c87308 to your computer and use it in GitHub Desktop.
javascriptissexy
// 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