Commits

Jonathan Fine committed d641e50

call-apply.js: New file. Added arguments_to_array().

  • Participants
  • Parent commits 5147292

Comments (0)

Files changed (1)

File source/examples/call-apply.js

+// Things related to call and apply that JS programmers should know.
+
+
+// Standard names for native code functions.
+
+var array_slice = Array.prototype.slice;
+var function_call = Function.prototype.call;
+var function_apply = Function.prototype.apply;
+
+var arguments_to_array = function(args){
+
+  return array_slice.call(args);
+};
+
+
+(function()
+{
+    var args = (function(){return arguments;})(0,1,2,3);
+    '' + args === '[object Object]' || ddt();
+    '' + arguments_to_array(args) === '0,1,2,3' || ddt();
+})();