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
class Queue { | |
constructor(...elements) { | |
// Initializing the queue with given arguments | |
this.elements = [...elements]; | |
} | |
// Proxying the push/shift methods | |
push(...args) { | |
return this.elements.push(...args); | |
} | |
shift(...args) { |
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.defineProperty(o, /^[0-9]+$/, { | |
get : function() { }, | |
set : function() { }, | |
enumerate : function() { }, | |
writable : false, | |
configurable : false, | |
enumerable : 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 test = Object.create([].prototype); | |
test.[]=function(index) { | |
console.log("Reading index "+index); | |
return Array.[].call(this,index); | |
} |
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
{ | |
"name" : "FranceJS" | |
, "version" : "0.0.1" | |
, "dependencies" : { | |
"jslovers" : "*", | |
"parisjs" : "*", | |
"toulousejs" : "*", | |
"lyonjs" : "*", | |
"lillejs" : "*" | |
} |
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
# Json | |
{ | |
"truc":"bidule", | |
"truc2":"bidule2", | |
"truc3":"bidule3" | |
"tab": | |
[ | |
"machin", | |
"bidule", | |
"truc" |
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
if(function test(a){console.log(a)}) { console.log(test('test')) } | |
// ReferenceError : test is not defined | |
var test; | |
if(test = (function(a){console.log(a)})) { console.log(test('test')) } | |
// test |
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
(function () {}).apply(this,new Array(1000000)) | |
// RangeError: Maximum call stack size exceeded |
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 str="<h2>Blahblah</h2><p>Blahblah Blahblah Blahblah.</p><h2>Blahblah</h2><p style=\"text-align: center;\"> <img alt=\"Blahblah\" src=\"http://www.example.com/images/blah.jpg\" /></p><p>BlahblahBlahblah Blahblah Blahblah.</p><h2>Blahblah</h2><p>Blahblah</p>"; | |
var regExp=new RegExp('<([^>]+)"([^>]*)>','mg'); | |
var pattern='<$1$2>'; | |
while(regExp.test(str)) | |
str = str.replace(regExp, pattern); | |
console.log(str); | |
// outputs | |
// <h2>Blahblah</h2><p>Blahblah Blahblah Blahblah.</p><h2>Blahblah</h2><p style=text-align: center;> <img alt="Blahblah" src=http://www.example.com/images/blah.jpg /></p><p>BlahblahBlahblah Blahblah Blahblah.</p><h2>Blahblah</h2><p>Blahblah</p> | |
// Notice the " in the img alt attribute |
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
// Chainable API for URIBuilder | |
var uri = new URLBuilder(logErrorHandler) | |
.parse('bad_url_format') | |
.addQueryParam('param','value') | |
.setPort('443') | |
.toString(); | |
function logErrorHandler(err, url_object){ | |
if('parse_error'===err.type) |
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
// Chaining API for URIBuilder | |
var uri=new URLBuilder().parse('bad_url_format').addQueryParam('param','value').setPort('443').toString(); | |
// How to handle the bad url parse error ? | |
// Don't want to throw exception | |
// Can't return null |