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
<script src='LABjs/LAB.min.js'></script> | |
<script> | |
<!-- | |
$LAB | |
.setOptions({BasePath:'/syntaxhighlight/js/'}) | |
.script('shCore.js', | |
'shBrushCpp.js', | |
'shBrushCss.js', | |
'shBrushJScript.js', | |
'shBrushPython.js', |
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
function cloneObj(obj) { | |
var clone; | |
if (Object.prototype.toString.call(obj) === "[object Array]") { | |
clone = []; | |
for (var i=0, len=obj.length; i<len; i++) { | |
clone[i] = cloneObj(obj[i]); | |
} | |
} | |
else if (obj == null) { | |
clone = obj; |
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>Custom Error Objects in JavaScript</title> | |
</head> | |
<body> | |
<h1>Custom Error Objects in JavaScript</h1> |
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
(function(){ | |
alert(window); // "undefined" | |
var window = window; | |
})(); |
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
// for FF only | |
setTimeout(function(rand){ alert(rand); },10); // FF passes a "magic" param we call "rand" | |
for (var i=0; i<100000; i++) { i; } // take some time |
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
(function(){ | |
var x = y = 1; | |
})(); | |
alert(x); // undefined | |
alert(y); // 1 -- oops, auto-global! |
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
#include <v8.h> | |
#include <fcntl.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <engine.h> | |
// Extracts a C string from a V8 Utf8Value. | |
const char* ToCString(const v8::String::Utf8Value& value) { |
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
(function(global){ | |
var undef; | |
function Promise(){} | |
Promise.prototype.constructor = Promise; | |
global.promise = function(cb) { | |
var publicAPI, queue = [], old_ret, promise_fulfilled = false; | |
function fulfill(val) { | |
var ret_val = val; |
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
var Require = function() { | |
function NativeRequire(module) { | |
var source; | |
// read source from file | |
if (!FS) { | |
source = imports.FSREAD("modules/fs.js"); | |
FS = Function.apply(Function,imports_names.concat([source])).apply(Function,imports_funcs); | |
} | |
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
function cloneObj(obj) { | |
var clone; | |
if (Object.prototype.toString.call(obj) === "[object Array]") { | |
clone = []; | |
for (var i=0, len=obj.length; i<len; i++) { | |
clone[i] = cloneObj(obj[i]); | |
} | |
} | |
else if (obj == null) { | |
clone = obj; |
OlderNewer