Advertisement
Guest User

Untitled

a guest
Feb 9th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.96 KB | None | 0 0
  1. var functionOne = function() {
  2. // Some code
  3. };
  4.  
  5. function functionTwo() {
  6. // Some code
  7. }
  8.  
  9. if (test) {
  10. // Error or misbehavior
  11. function functionThree() { doSomething(); }
  12. }
  13.  
  14. function xyz(){
  15. function abc(){};
  16. // abc is defined here...
  17. }
  18. // ...but not here
  19.  
  20. var xyz = function abc(){};
  21.  
  22. var xyz = function abc(){
  23. // xyz is visible here
  24. // abc is visible here
  25. }
  26. // xyz is visible here
  27. // abc is undefined here
  28.  
  29. function abc(){};
  30. var xyz = abc;
  31.  
  32. console.log(xyz === abc); // prints "true"
  33.  
  34. function abc(){};
  35. console.log(abc.name); // prints "abc"
  36.  
  37. var abc = function(){};
  38. console.log(abc.name); // prints ""
  39.  
  40. // Assume really.long.external.scoped is {}
  41. really.long.external.scoped.name = function shortcut(n){
  42. // Let it call itself recursively:
  43. shortcut(n - 1);
  44. // ...
  45. // Let it pass itself as a callback:
  46. someFunction(shortcut);
  47. // ...
  48. }
  49.  
  50. function abc(){}
  51.  
  52. // We can call it here
  53. abc(); // Works
  54.  
  55. // Yet, it is defined down there.
  56. function abc(){}
  57.  
  58. // We can call it again
  59. abc(); // Works
  60.  
  61. // We can call it here
  62. abc(); // Works
  63. return;
  64. function abc(){}
  65.  
  66. var xyz = function(){};
  67.  
  68. // We can't call it here
  69. xyz(); // UNDEFINED!!!
  70.  
  71. // Now it is defined
  72. xyz = function(){}
  73.  
  74. // We can call it here
  75. xyz(); // works
  76.  
  77. var xyz = function abc(){};
  78. console.log(xyz.name); // Prints "abc"
  79.  
  80. var abc = function(){};
  81.  
  82. abc = function(){};
  83.  
  84. function abc(){};
  85.  
  86. function x() {
  87. console.log('x');
  88. }
  89.  
  90. x(); // Works even though it's above the declaration
  91. function x() {
  92. console.log('x');
  93. }
  94.  
  95. if (someCondition) {
  96. function foo() { // <===== HERE THERE
  97. } // <===== BE DRAGONS
  98. }
  99.  
  100. "use strict";
  101. if (someCondition) {
  102. foo(); // Works just fine
  103. function foo() {
  104. }
  105. }
  106. console.log(typeof foo); // "undefined" (`foo` is not in scope here
  107. // because it's not in the same block)
  108.  
  109. var y = function () {
  110. console.log('y');
  111. };
  112.  
  113. var z = function w() {
  114. console.log('zw')
  115. };
  116.  
  117. var z = function w() {
  118. console.log(typeof w); // "function"
  119. };
  120. console.log(typeof w); // "undefined"
  121.  
  122. var obj = {
  123. value: 0,
  124. get f() {
  125. return this.value;
  126. },
  127. set f(v) {
  128. this.value = v;
  129. }
  130. };
  131. console.log(obj.f); // 0
  132. console.log(typeof obj.f); // "number"
  133.  
  134. var a = [1, 2, 3];
  135. var b = a.map(n => n * 2);
  136. console.log(b.join(", ")); // 2, 4, 6
  137.  
  138. var a = [1, 2, 3];
  139. var b = a.map((n, i) => n * i);
  140. console.log(b.join(", ")); // 0, 2, 6
  141.  
  142. var a = [
  143. {first: "Joe", last: "Bloggs"},
  144. {first: "Albert", last: "Bloggs"},
  145. {first: "Mary", last: "Albright"}
  146. ];
  147. a = a.sort((a, b) => {
  148. var rv = a.last.localeCompare(b.last);
  149. if (rv === 0) {
  150. rv = a.first.localeCompare(b.first);
  151. }
  152. return rv;
  153. });
  154. console.log(JSON.stringify(a));
  155.  
  156. var o = {
  157. foo() {
  158. }
  159. };
  160.  
  161. var o = {
  162. foo: function foo() {
  163. }
  164. };
  165.  
  166. class Person {
  167. constructor(firstName, lastName) {
  168. this.firstName = firstName;
  169. this.lastName = lastName;
  170. }
  171.  
  172. getFullName() {
  173. return this.firstName + " " + this.lastName;
  174. }
  175. }
  176.  
  177. alert(typeof foo); // 'function', it's already available
  178. alert(typeof bar); // 'undefined'
  179. function foo () {}
  180. var bar = function () {};
  181. alert(typeof bar); // 'function'
  182.  
  183. function test () {}
  184. test = null;
  185.  
  186. (function(){
  187. var exports = {};
  188.  
  189. function privateUtil() {
  190. ...
  191. }
  192.  
  193. exports.publicUtil = function() {
  194. ...
  195. };
  196.  
  197. return exports;
  198. })();
  199.  
  200. functionTwo();
  201. function functionTwo() {
  202. }
  203.  
  204. functionOne(); --------------- var functionOne;
  205. | is actually | functionOne();
  206. var functionOne = function(){ | interpreted |-->
  207. }; | like | functionOne = function(){
  208. --------------- };
  209.  
  210. functionTwo(); --------------- function functionTwo() {
  211. | is actually | };
  212. function functionTwo() { | interpreted |-->
  213. } | like | functionTwo();
  214. ---------------
  215.  
  216. if (condition){
  217. function myfunction(){
  218. // some code
  219. }
  220. }
  221.  
  222. if (condition){
  223. var myfunction = function (){
  224. // some code
  225. }
  226. }
  227.  
  228. var MyNamespace = {}
  229. MyNamespace.foo= function() {
  230.  
  231. }
  232.  
  233. var MyNamespace = {
  234. foo: function() {
  235. },
  236. ...
  237. }
  238.  
  239. var foo = 1;
  240. function bar() {
  241. if (!foo) {
  242. var foo = 10 }
  243. return foo; }
  244. bar() // 10
  245.  
  246. function f() {
  247. return a;
  248. function a() {return 1};
  249. var a = 4;
  250. function a() {return 2}}
  251. f()() // 2
  252.  
  253. function f() {
  254. return a;
  255. var a = 4;
  256. function a() {return 1};
  257. function a() {return 2}}
  258. f()() // 2
  259.  
  260. function f() {
  261. var a = 4;
  262. function a() {return 1};
  263. function a() {return 2};
  264. return a; }
  265. f() // 4
  266.  
  267. var a = 1;
  268. function b() {
  269. a = 10;
  270. return;
  271. function a() {}}
  272. b();
  273. a // 1
  274.  
  275. global_Page = 10; var global_Page; « undefined
  276. « Integer literal, Number Type. ------------------- global_Page = 10; « Number
  277. global_Page = 'Yash'; | Interpreted | global_Page = 'Yash'; « String
  278. « String literal, String Type. « AS « global_Page = true; « Boolean
  279. var global_Page = true; | | global_Page = function (){ « function
  280. « Boolean Type ------------------- var local_functionblock; « undefined
  281. global_Page = function (){ local_functionblock = 777;« Number
  282. var local_functionblock = 777; };
  283. // Assigning function as a data.
  284. };
  285.  
  286. function Identifier_opt ( FormalParameterList_opt ) {
  287. FunctionBody | sequence of statements
  288.  
  289. « return; Default undefined
  290. « return 'some data';
  291. }
  292.  
  293. Scope with respect to function-block global.
  294. Scope with respect to page undefined | not available.
  295.  
  296. function globalAccess() { function globalAccess() {
  297. } ------------------- }
  298. globalAccess(); | | function globalAccess() { « Re-Defined / overridden.
  299. localAccess(); « Hoisted As « function localAccess() {
  300. function globalAccess() { | | }
  301. localAccess(); ------------------- localAccess(); « function accessed with in globalAccess() only.
  302. function localAccess() { }
  303. } globalAccess();
  304. } localAccess(); « ReferenceError as the function is not defined
  305.  
  306. 10; « literal
  307. (10); « Expression (10).toString() -> '10'
  308. var a;
  309. a = 10; « Expression var a.toString() -> '10'
  310. (function invoke() { « Expression Function
  311. console.log('Self Invoking'); (function () {
  312. }); }) () -> 'Self Invoking'
  313.  
  314. var f;
  315. f = function (){ « Expression var Function
  316. console.log('var Function'); f () -> 'var Function'
  317. };
  318.  
  319. (function selfExecuting(){
  320. console.log('IIFE - Immediately-Invoked Function Expression');
  321. }());
  322.  
  323. var anonymous = function (){
  324. console.log('anonymous function Expression');
  325. };
  326.  
  327. var namedExpression = function for_InternalUSE(fact){
  328. if(fact === 1){
  329. return 1;
  330. }
  331.  
  332. var localExpression = function(){
  333. console.log('Local to the parent Function Scope');
  334. };
  335. globalExpression = function(){
  336. console.log('creates a new global variable, then assigned this function.');
  337. };
  338.  
  339. //return; //undefined.
  340. return fact * for_InternalUSE( fact - 1);
  341. };
  342.  
  343. namedExpression();
  344. globalExpression();
  345.  
  346. var anonymous;
  347. var namedExpression;
  348. var globalExpression;
  349.  
  350. anonymous = function (){
  351. console.log('anonymous function Expression');
  352. };
  353.  
  354. namedExpression = function for_InternalUSE(fact){
  355. var localExpression;
  356.  
  357. if(fact === 1){
  358. return 1;
  359. }
  360. localExpression = function(){
  361. console.log('Local to the parent Function Scope');
  362. };
  363. globalExpression = function(){
  364. console.log('creates a new global variable, then assigned this function.');
  365. };
  366.  
  367. return fact * for_InternalUSE( fact - 1); // DEFAULT UNDEFINED.
  368. };
  369.  
  370. namedExpression(10);
  371. globalExpression();
  372.  
  373. function abc(){}
  374.  
  375. var abc = function() {};
  376.  
  377. //this will work
  378. abc(param);
  379. function abc(){}
  380.  
  381. //this would fail
  382. abc(param);
  383. var abc = function() {}
  384.  
  385. {
  386. member:function() { /* How do I make "this.member" a named function? */
  387. }
  388. }
  389.  
  390. var foo = function foo() {};
  391.  
  392. function foo() {};
  393.  
  394. function foo() {};
  395.  
  396. var foo = function foo() {};
  397.  
  398. var foo = undefined;
  399. foo = function foo() {};
  400.  
  401. var ninja = {
  402. yell: function(n){
  403. return n > 0 ? ninja.yell(n-1) + "a" : "hiy";
  404. }
  405. };
  406. assert( ninja.yell(4) == "hiyaaaa", "A single object isn't too bad, either." );
  407.  
  408. var samurai = { yell: ninja.yell };
  409. var ninja = null;
  410.  
  411. try {
  412. samurai.yell(4);
  413. } catch(e){
  414. assert( false, "Uh, this isn't good! Where'd ninja.yell go?" );
  415. }
  416.  
  417. var ninja = {
  418. yell: function yell(n){
  419. return n > 0 ? yell(n-1) + "a" : "hiy";
  420. }
  421. };
  422. assert( ninja.yell(4) == "hiyaaaa", "Works as we would expect it to!" );
  423.  
  424. var samurai = { yell: ninja.yell };
  425. var ninja = {};
  426. assert( samurai.yell(4) == "hiyaaaa", "The method correctly calls itself." );
  427.  
  428. var functionOne = function() {
  429. // Some code
  430. };
  431.  
  432. var one = new functionOne();
  433.  
  434. function functionTwo() {
  435. // Some code
  436. }
  437. two = new functionTwo();
  438.  
  439. var objectOne = new functionOne();
  440. console.log(objectOne.__proto__); // prints "Object {}" because constructor is an anonymous function
  441.  
  442. var objectTwo = new functionTwo();
  443. console.log(objectTwo.__proto__); // prints "functionTwo {}" because constructor is a named function
  444.  
  445. function outerFunction() {
  446. function foo() {
  447. return 1;
  448. }
  449. return foo();
  450. function foo() {
  451. return 2;
  452. }
  453. }
  454. alert(outerFunction()); // Displays 2
  455.  
  456. function foo() { // The first function declaration is moved to top
  457. return 1;
  458. }
  459. function foo() { // The second function declaration is moved to top
  460. return 2;
  461. }
  462. function outerFunction() {
  463. return foo();
  464. }
  465. alert(outerFunction()); //So executing from top to bottom,
  466. //the last foo() returns 2 which gets displayed
  467.  
  468. function outerFunction() {
  469. var foo = function() {
  470. return 1;
  471. }
  472. return foo();
  473. var foo = function() {
  474. return 2;
  475. }
  476. }
  477. alert(outerFunction()); // Displays 1
  478.  
  479. function outerFunction() {
  480. var foo = undefined;
  481. var foo = undefined;
  482.  
  483. foo = function() {
  484. return 1;
  485. };
  486. return foo ();
  487. foo = function() { // This function expression is not reachable
  488. return 2;
  489. };
  490. }
  491. alert(outerFunction()); // Displays 1
  492.  
  493. if (test) {
  494. function x() { doSomething(); }
  495. }
  496.  
  497. var today = function today() {return new Date()}
  498.  
  499. function foo() {
  500. return 3;
  501. }
  502.  
  503. // Anonymous function expression
  504. var a = function() {
  505. return 3;
  506. }
  507.  
  508. // Named function expression
  509. var a = function foo() {
  510. return 3;
  511. }
  512.  
  513. // Self-invoking function expression
  514. (function foo() {
  515. alert("hello!");
  516. })();
  517.  
  518. [].forEach(function iterator() {});
  519.  
  520. 'use strict';
  521.  
  522. var a = function () {
  523. throw new Error();
  524. },
  525. b = function b() {
  526. throw new Error();
  527. },
  528. c = function d() {
  529. throw new Error();
  530. },
  531. e = {
  532. f: a,
  533. g: b,
  534. h: c,
  535. i: function () {
  536. throw new Error();
  537. },
  538. j: function j() {
  539. throw new Error();
  540. },
  541. k: function l() {
  542. throw new Error();
  543. }
  544. },
  545. m = (function () {
  546. return function () {
  547. throw new Error();
  548. };
  549. }()),
  550. n = (function () {
  551. return function n() {
  552. throw new Error();
  553. };
  554. }()),
  555. o = (function () {
  556. return function p() {
  557. throw new Error();
  558. };
  559. }());
  560.  
  561. console.log([a, b, c].concat(Object.keys(e).reduce(function (values, key) {
  562. return values.concat(e[key]);
  563. }, [])).concat([m, n, o]).reduce(function (logs, func) {
  564.  
  565. try {
  566. func();
  567. } catch (error) {
  568. return logs.concat('func.name: ' + func.name + 'n' +
  569. 'Trace:n' +
  570. error.stack);
  571. // Need to manually log the error object in Nitro.
  572. }
  573.  
  574. }, []).join('nn'));
  575.  
  576. func.name:
  577. Trace:
  578. Error
  579. at a (http://localhost:8000/test.js:4:11)
  580. at http://localhost:8000/test.js:47:9
  581. at Array.reduce (native)
  582. at http://localhost:8000/test.js:44:27
  583.  
  584. func.name: b
  585. Trace:
  586. Error
  587. at b (http://localhost:8000/test.js:7:15)
  588. at http://localhost:8000/test.js:47:9
  589. at Array.reduce (native)
  590. at http://localhost:8000/test.js:44:27
  591.  
  592. func.name: d
  593. Trace:
  594. Error
  595. at d (http://localhost:8000/test.js:10:15)
  596. at http://localhost:8000/test.js:47:9
  597. at Array.reduce (native)
  598. at http://localhost:8000/test.js:44:27
  599.  
  600. func.name:
  601. Trace:
  602. Error
  603. at a (http://localhost:8000/test.js:4:11)
  604. at http://localhost:8000/test.js:47:9
  605. at Array.reduce (native)
  606. at http://localhost:8000/test.js:44:27
  607.  
  608. func.name: b
  609. Trace:
  610. Error
  611. at b (http://localhost:8000/test.js:7:15)
  612. at http://localhost:8000/test.js:47:9
  613. at Array.reduce (native)
  614. at http://localhost:8000/test.js:44:27
  615.  
  616. func.name: d
  617. Trace:
  618. Error
  619. at d (http://localhost:8000/test.js:10:15)
  620. at http://localhost:8000/test.js:47:9
  621. at Array.reduce (native)
  622. at http://localhost:8000/test.js:44:27
  623.  
  624. func.name:
  625. Trace:
  626. Error
  627. at e.i (http://localhost:8000/test.js:17:19)
  628. at http://localhost:8000/test.js:47:9
  629. at Array.reduce (native)
  630. at http://localhost:8000/test.js:44:27
  631.  
  632. func.name: j
  633. Trace:
  634. Error
  635. at j (http://localhost:8000/test.js:20:19)
  636. at http://localhost:8000/test.js:47:9
  637. at Array.reduce (native)
  638. at http://localhost:8000/test.js:44:27
  639.  
  640. func.name: l
  641. Trace:
  642. Error
  643. at l (http://localhost:8000/test.js:23:19)
  644. at http://localhost:8000/test.js:47:9
  645. at Array.reduce (native)
  646. at http://localhost:8000/test.js:44:27
  647.  
  648. func.name:
  649. Trace:
  650. Error
  651. at http://localhost:8000/test.js:28:19
  652. at http://localhost:8000/test.js:47:9
  653. at Array.reduce (native)
  654. at http://localhost:8000/test.js:44:27
  655.  
  656. func.name: n
  657. Trace:
  658. Error
  659. at n (http://localhost:8000/test.js:33:19)
  660. at http://localhost:8000/test.js:47:9
  661. at Array.reduce (native)
  662. at http://localhost:8000/test.js:44:27
  663.  
  664. func.name: p
  665. Trace:
  666. Error
  667. at p (http://localhost:8000/test.js:38:19)
  668. at http://localhost:8000/test.js:47:9
  669. at Array.reduce (native)
  670. at http://localhost:8000/test.js:44:27 test.js:42
  671.  
  672. func.name:
  673. Trace:
  674. a@http://localhost:8000/test.js:4:5
  675. @http://localhost:8000/test.js:47:9
  676. @http://localhost:8000/test.js:54:1
  677.  
  678.  
  679. func.name: b
  680. Trace:
  681. b@http://localhost:8000/test.js:7:9
  682. @http://localhost:8000/test.js:47:9
  683. @http://localhost:8000/test.js:54:1
  684.  
  685.  
  686. func.name: d
  687. Trace:
  688. d@http://localhost:8000/test.js:10:9
  689. @http://localhost:8000/test.js:47:9
  690. @http://localhost:8000/test.js:54:1
  691.  
  692.  
  693. func.name:
  694. Trace:
  695. a@http://localhost:8000/test.js:4:5
  696. @http://localhost:8000/test.js:47:9
  697. @http://localhost:8000/test.js:54:1
  698.  
  699.  
  700. func.name: b
  701. Trace:
  702. b@http://localhost:8000/test.js:7:9
  703. @http://localhost:8000/test.js:47:9
  704. @http://localhost:8000/test.js:54:1
  705.  
  706.  
  707. func.name: d
  708. Trace:
  709. d@http://localhost:8000/test.js:10:9
  710. @http://localhost:8000/test.js:47:9
  711. @http://localhost:8000/test.js:54:1
  712.  
  713.  
  714. func.name:
  715. Trace:
  716. e.i@http://localhost:8000/test.js:17:13
  717. @http://localhost:8000/test.js:47:9
  718. @http://localhost:8000/test.js:54:1
  719.  
  720.  
  721. func.name: j
  722. Trace:
  723. j@http://localhost:8000/test.js:20:13
  724. @http://localhost:8000/test.js:47:9
  725. @http://localhost:8000/test.js:54:1
  726.  
  727.  
  728. func.name: l
  729. Trace:
  730. l@http://localhost:8000/test.js:23:13
  731. @http://localhost:8000/test.js:47:9
  732. @http://localhost:8000/test.js:54:1
  733.  
  734.  
  735. func.name:
  736. Trace:
  737. m</<@http://localhost:8000/test.js:28:13
  738. @http://localhost:8000/test.js:47:9
  739. @http://localhost:8000/test.js:54:1
  740.  
  741.  
  742. func.name: n
  743. Trace:
  744. n@http://localhost:8000/test.js:33:13
  745. @http://localhost:8000/test.js:47:9
  746. @http://localhost:8000/test.js:54:1
  747.  
  748.  
  749. func.name: p
  750. Trace:
  751. p@http://localhost:8000/test.js:38:13
  752. @http://localhost:8000/test.js:47:9
  753. @http://localhost:8000/test.js:54:1
  754.  
  755. func.name: undefined
  756. Trace:
  757. Error
  758. at a (http://localhost:8000/test.js:4:5)
  759. at Anonymous function (http://localhost:8000/test.js:47:9)
  760. at Global code (http://localhost:8000/test.js:42:1)
  761.  
  762.  
  763. func.name: undefined
  764. Trace:
  765. Error
  766. at b (http://localhost:8000/test.js:7:9)
  767. at Anonymous function (http://localhost:8000/test.js:47:9)
  768. at Global code (http://localhost:8000/test.js:42:1)
  769.  
  770.  
  771. func.name: undefined
  772. Trace:
  773. Error
  774. at d (http://localhost:8000/test.js:10:9)
  775. at Anonymous function (http://localhost:8000/test.js:47:9)
  776. at Global code (http://localhost:8000/test.js:42:1)
  777.  
  778.  
  779. func.name: undefined
  780. Trace:
  781. Error
  782. at a (http://localhost:8000/test.js:4:5)
  783. at Anonymous function (http://localhost:8000/test.js:47:9)
  784. at Global code (http://localhost:8000/test.js:42:1)
  785.  
  786.  
  787. func.name: undefined
  788. Trace:
  789. Error
  790. at b (http://localhost:8000/test.js:7:9)
  791. at Anonymous function (http://localhost:8000/test.js:47:9)
  792. at Global code (http://localhost:8000/test.js:42:1)
  793.  
  794.  
  795. func.name: undefined
  796. Trace:
  797. Error
  798. at d (http://localhost:8000/test.js:10:9)
  799. at Anonymous function (http://localhost:8000/test.js:47:9)
  800. at Global code (http://localhost:8000/test.js:42:1)
  801.  
  802.  
  803. func.name: undefined
  804. Trace:
  805. Error
  806. at e.i (http://localhost:8000/test.js:17:13)
  807. at Anonymous function (http://localhost:8000/test.js:47:9)
  808. at Global code (http://localhost:8000/test.js:42:1)
  809.  
  810.  
  811. func.name: undefined
  812. Trace:
  813. Error
  814. at j (http://localhost:8000/test.js:20:13)
  815. at Anonymous function (http://localhost:8000/test.js:47:9)
  816. at Global code (http://localhost:8000/test.js:42:1)
  817.  
  818.  
  819. func.name: undefined
  820. Trace:
  821. Error
  822. at l (http://localhost:8000/test.js:23:13)
  823. at Anonymous function (http://localhost:8000/test.js:47:9)
  824. at Global code (http://localhost:8000/test.js:42:1)
  825.  
  826.  
  827. func.name: undefined
  828. Trace:
  829. Error
  830. at Anonymous function (http://localhost:8000/test.js:28:13)
  831. at Anonymous function (http://localhost:8000/test.js:47:9)
  832. at Global code (http://localhost:8000/test.js:42:1)
  833.  
  834.  
  835. func.name: undefined
  836. Trace:
  837. Error
  838. at n (http://localhost:8000/test.js:33:13)
  839. at Anonymous function (http://localhost:8000/test.js:47:9)
  840. at Global code (http://localhost:8000/test.js:42:1)
  841.  
  842.  
  843. func.name: undefined
  844. Trace:
  845. Error
  846. at p (http://localhost:8000/test.js:38:13)
  847. at Anonymous function (http://localhost:8000/test.js:47:9)
  848. at Global code (http://localhost:8000/test.js:42:1)
  849.  
  850. func.name:
  851. Trace:
  852. a@http://localhost:8000/test.js:4:22
  853. http://localhost:8000/test.js:47:13
  854. reduce@[native code]
  855. global code@http://localhost:8000/test.js:44:33
  856.  
  857. func.name: b
  858. Trace:
  859. b@http://localhost:8000/test.js:7:26
  860. http://localhost:8000/test.js:47:13
  861. reduce@[native code]
  862. global code@http://localhost:8000/test.js:44:33
  863.  
  864. func.name: d
  865. Trace:
  866. d@http://localhost:8000/test.js:10:26
  867. http://localhost:8000/test.js:47:13
  868. reduce@[native code]
  869. global code@http://localhost:8000/test.js:44:33
  870.  
  871. func.name:
  872. Trace:
  873. a@http://localhost:8000/test.js:4:22
  874. http://localhost:8000/test.js:47:13
  875. reduce@[native code]
  876. global code@http://localhost:8000/test.js:44:33
  877.  
  878. func.name: b
  879. Trace:
  880. b@http://localhost:8000/test.js:7:26
  881. http://localhost:8000/test.js:47:13
  882. reduce@[native code]
  883. global code@http://localhost:8000/test.js:44:33
  884.  
  885. func.name: d
  886. Trace:
  887. d@http://localhost:8000/test.js:10:26
  888. http://localhost:8000/test.js:47:13
  889. reduce@[native code]
  890. global code@http://localhost:8000/test.js:44:33
  891.  
  892. func.name:
  893. Trace:
  894. i@http://localhost:8000/test.js:17:30
  895. http://localhost:8000/test.js:47:13
  896. reduce@[native code]
  897. global code@http://localhost:8000/test.js:44:33
  898.  
  899. func.name: j
  900. Trace:
  901. j@http://localhost:8000/test.js:20:30
  902. http://localhost:8000/test.js:47:13
  903. reduce@[native code]
  904. global code@http://localhost:8000/test.js:44:33
  905.  
  906. func.name: l
  907. Trace:
  908. l@http://localhost:8000/test.js:23:30
  909. http://localhost:8000/test.js:47:13
  910. reduce@[native code]
  911. global code@http://localhost:8000/test.js:44:33
  912.  
  913. func.name:
  914. Trace:
  915. http://localhost:8000/test.js:28:30
  916. http://localhost:8000/test.js:47:13
  917. reduce@[native code]
  918. global code@http://localhost:8000/test.js:44:33
  919.  
  920. func.name: n
  921. Trace:
  922. n@http://localhost:8000/test.js:33:30
  923. http://localhost:8000/test.js:47:13
  924. reduce@[native code]
  925. global code@http://localhost:8000/test.js:44:33
  926.  
  927. func.name: p
  928. Trace:
  929. p@http://localhost:8000/test.js:38:30
  930. http://localhost:8000/test.js:47:13
  931. reduce@[native code]
  932. global code@http://localhost:8000/test.js:44:33
  933.  
  934. functionOne();
  935. var functionOne = function() {
  936. // Some code
  937. };
  938.  
  939. functionOne();
  940. function functionOne() {
  941. // Some code
  942. }
  943.  
  944. function fn(){
  945. console.log("Hello");
  946. }
  947. fn();
  948.  
  949. var fn=function(){
  950. console.log("Hello");
  951. }
  952. fn();
  953.  
  954. var func = new Function("x", "y", "return x*y;");
  955. function secondFunction(){
  956. var result;
  957. result = func(10,20);
  958. console.log ( result );
  959. }
  960.  
  961. secondFunction()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement