A Pen by Suman Paul on CodePen.
This file contains hidden or 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 validator = (function () { | |
function trim(str) { | |
return str.replace(/^\s+|\s+$/g, ''); | |
} | |
function isEmail(field) { | |
if (field) { | |
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; | |
if (!filter.test(field)) { | |
return false; |
This file contains hidden or 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 cat = function(obj){ | |
//this is where I copy all the attributes of the passed object to the constructure | |
for (attr in obj){ | |
this[attr] = obj[attr]; | |
} | |
//publice method | |
this.talk = function(){ | |
console.log('meeow!!!'); | |
}; | |
}; |
This file contains hidden or 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 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); |
This file contains hidden or 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 cardJSON1 = { | |
text:'this is text', | |
color:'red', | |
position:{ | |
x:200, | |
y:200 | |
} | |
}; | |
var cardJSON2 = { |
This file contains hidden or 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 fs = require('fs'); | |
fs.createReadStream('test.log').pipe(fs.createWriteStream('newLog.log')); |
This file contains hidden or 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
{ | |
"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, |
This file contains hidden or 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
Show hidden characters
{ | |
"node": true, | |
"browser": true, | |
"esnext": true, | |
"bitwise": true, | |
"camelcase": false, | |
"curly": true, | |
"eqeqeq": true, | |
"immed": true, | |
"indent": 2, |
This file contains hidden or 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
//Object Properties | |
Object.length; //returns 1 | |
Object.prototype; //returns {} |
This file contains hidden or 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 user = { | |
firstName: 'Suman', | |
lastName: 'Paul', | |
age: 30 | |
}; | |
Object.keys(user); | |
//returns ["firstName", "lastName", "age"] |
OlderNewer