Skip to content

Instantly share code, notes, and snippets.

var a = [1,2,3];
Object.keys(a);
//returns ["0", "1", "2"]
Object.getOwnPropertyNames(a)
//returns ["0", "1", "2", "length"]
a.propertyIsEnumerable(0); // returns true
a.propertyIsEnumerable('length'); // returns false
var user = {
firstName: 'Suman',
lastName: 'Paul',
age: 30
};
Object.defineProperty(user, 'gender', {
enumerable: false,
value: 'male'
});
var user = {
firstName: 'Suman',
lastName: 'Paul',
age: 30
};
Object.keys(user);
//returns ["firstName", "lastName", "age"]
//Object Properties
Object.length; //returns 1
Object.prototype; //returns {}
@skeep
skeep / .jshintrc
Created January 9, 2014 10:02
JS Hint config
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": false,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
@skeep
skeep / .jsbeautifyrc
Created January 9, 2014 10:02
je beautify config
{
"indent_size": 2,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"jslint_happy": true,
"brace_style": "collapse",
"keep_array_indentation": false,
@skeep
skeep / A-Pen-by-Suman-Paul.markdown
Created September 19, 2013 20:31
A Pen by Suman Paul.
var fs = require('fs');
fs.createReadStream('test.log').pipe(fs.createWriteStream('newLog.log'));
@skeep
skeep / gist:4762019
Last active December 12, 2015 10:49
var cardJSON1 = {
text:'this is text',
color:'red',
position:{
x:200,
y:200
}
};
var cardJSON2 = {
var cardJSON = {
text:'this is text',
color:'red'
};
var Card = function(obj){
var that = this;
var props = Object.getOwnPropertyNames(obj);
props.forEach(function(prop){
var propDescriptor = Object.getOwnPropertyDescriptor(obj, prop);