Skip to content

Instantly share code, notes, and snippets.

View getify's full-sized avatar
💭
Just coding

Kyle Simpson getify

💭
Just coding
View GitHub Profile
<script src='LABjs/LAB.min.js'></script>
<script>
<!--
$LAB
.setOptions({BasePath:'/syntaxhighlight/js/'})
.script('shCore.js',
'shBrushCpp.js',
'shBrushCss.js',
'shBrushJScript.js',
'shBrushPython.js',
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;
<!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>
(function(){
alert(window); // "undefined"
var window = window;
})();
// 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
(function(){
var x = y = 1;
})();
alert(x); // undefined
alert(y); // 1 -- oops, auto-global!
#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) {
(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;
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);
}
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;