Question: PHP funcitons are written in C and you can look at the source code if you like. For example here - 
[session\_start source](http://lxr.php.net/opengrok/xref/PHP_5_3/ext/session/session.c#1361)

What about with Javascript? How are functions like JSON.parse implemented? Where can I go to view the source?

Thanks!

Answer: 
JSON.parse is native. That means it's defined in the browser, the implementation of the method is browser implementation specific.

v8 (Chrome) has a C++ method for [`JsonParser::ParseJson`](https://code.google.com/p/v8/codesearch#v8/trunk/src/json-parser.h)

spidermonkey (Firefox) has a C++ function for [`js_json_parse`](http://hg.mozilla.org/mozilla-central/file/964b118ac852/js/src/json.cpp#l90)

JavaScriptCore (Webkit / Safari) has a C++ function for [`JSONProtoFuncParse`](http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/runtime/JSONObject.cpp#L824)

Rhino (Mozilla) has a Java method for [`parseValue`](https://github.com/mozilla/rhino/blob/master/src/org/mozilla/javascript/json/JsonParser.java#L71)

the Opera and IE implementations are closed source. I also think Nitro's implementation is closed source aswell.

Note there are many other JavaScript engines.
Each JavaScript engine that supports it will have its own implementation of `JSON.parse`. You can view the code of the various open source engines ([V8](http://code.google.com/p/v8/), [SpiderMonkey](https://developer.mozilla.org/en/SpiderMonkey)) in their respective repositories. You can also view a JavaScript implementation on [Crockford's github page](https://github.com/douglascrockford/JSON-js/) (Crockford being the person who came up with [JSON](http://json.org)) — actually, more than one; there's a version that's a state machine, and another that's a recursive descent parser, and another that relies on `eval` (which is kind of cheating). There are also various implementations in various languages linked from the [JSON home page](http://json.org).