Posts

Showing posts with the label type

Object.defineProperty ... but Strict!

In my precedent post entitled A Pascal record via JavaScript I have showed a basic function able to emulate type hints behavior via JavaScript. Even if that was a proof of concept, I consider other languages simulation of unsupported features an error, first of all because the behavior will rarely be exactly the expected one, secondly because our curent programming language may already have something similar to better learn and use. A new ES5( direction ) As soon as I have written the Pascal example, I have realized that the good "old" Object.defineProperty , implemented in all major browsers (IE The only missing part, intrinsic in the JavaScript nature, is the property type, where this type could be eventually used for arguments or returns checks when the property is a method. My Early Attempts Back in May 2007, my JavaStrict experiment was already trying to do something similar, something implemented after 2 years even in dojo framework as well. This may tell us that ...

94 bytes to quickly get a var type

I surpassed myself for the third time but I tweeted too much about, so here a quick one ;) // was getClassName but people prefer type // while kangax prefers var var type=(function(s,u){return function(o){return o==u?""+o:s.call(o).slice(8,-1)}})({}.toString);

Script Type PHP :)

Update 2008/03/15 I have removed preg_replace and added DOM classes to parse and manage, in a better way, script nodes that contain php code. Everything inside a simple PHP 5 compatible class . Finally, please remember that this is a layer between <?php ?> and JavaScript, and only an experiment ;) Here you can read another example, where difference between server, output, and client, should be more clear than precedent one. <?php require ' PHPScriptHandler.php '; ?> <html> <head> <title>Hello PHP World</title> <script type="text/php" author="andr3a"> // here we are between the server and output, known as client $hello = ucwords('hello php world'); // imagine that we would like to use a variable // defined somewhere in the server global $something; // we could even include or require php ...