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
/* by Dmitry A. Soshnikov */ | |
var object = (function () { | |
// private | |
var _x = 10; | |
// also private | |
function _privateFunc() { | |
return _x; |
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
/* by Dmitry A. Soshnikov */ | |
#include "stdafx.h" | |
#include <iostream> | |
struct Object { | |
int x; | |
int y; | |
}; |
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
/** | |
* Aliases and additional "sugar" | |
* 2010-04-15 | |
* @author Dmitry A. Soshnikov | |
*/ | |
(function () { | |
var | |
$break = {}, | |
hasOwn = Object.prototype.hasOwnProperty; |
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
C++ source: | |
void call_by_reference(int& x) | |
{ | |
x = 20; | |
} | |
void call_by_pointer(int* x) | |
{ | |
*x = 20; |
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
/** | |
* 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; |
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
/** | |
* 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 | |
* |
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
/** | |
* Delegation based mixins for JavaScript. | |
* | |
* Non-specific extensions are used: | |
* __proto__ | |
* __noSuchMethod__ | |
* | |
* Tested in SpiderMonkey. | |
* | |
* Opened issues: |
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
// 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 |
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
// 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; |
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
int main() | |
{ | |
int i = 0, n = 1; | |
while (i++ < n) if (i == 1) break; | |
while (i++ < n && i != 1); | |
return 0; | |
} |
OlderNewer