Skip to content

Instantly share code, notes, and snippets.

/* by Dmitry A. Soshnikov */
var object = (function () {
// private
var _x = 10;
// also private
function _privateFunc() {
return _x;
/* by Dmitry A. Soshnikov */
#include "stdafx.h"
#include <iostream>
struct Object {
int x;
int y;
};
/**
* Aliases and additional "sugar"
* 2010-04-15
* @author Dmitry A. Soshnikov
*/
(function () {
var
$break = {},
hasOwn = Object.prototype.hasOwnProperty;
C++ source:
void call_by_reference(int& x)
{
x = 20;
}
void call_by_pointer(int* x)
{
*x = 20;
/**
* by Dmitry A. Soshnikov
*/
Object.defineProperty(Object, "essence", {
value: function objectEssence(value) {
var essence = {kind: Object.prototype.toString.call(value).slice(8, -1)};
// use Object(value) just for shortness, it's less effective
// than typeof value == "object" && value !== null || typeof value == "function"
essence[value === Object(value) ? "object" : "primitive"] = true;
/**
* Abstract representation of ES3
* or ES5-non-strict sharing of
* passed formal parameters and
* corresponding indexes of the
* arguments object
*
* Implemented in ES5, non-strict
* tested in BESEN rev. 109
*
/**
* Delegation based mixins for JavaScript.
*
* Non-specific extensions are used:
* __proto__
* __noSuchMethod__
*
* Tested in SpiderMonkey.
*
* Opened issues:
// Latest Firefox (including nightly):
// INCORRECT with FDs
(function () {
// a function declaration
// does not replace arguments object
function arguments() {}
alert(arguments); // "[object Object]", should be function
// loop-code-gen.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int i = 0, n = 1;
int main()
{
int i = 0, n = 1;
while (i++ < n) if (i == 1) break;
while (i++ < n && i != 1);
return 0;
}