testlog.js 885 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Created by chen on 2017/9/13.
  3. */
  4. console.log(["1", "2", "3"].map(parseInt))
  5. var val = 'smtg';
  6. console.log('Value is ' + (val === 'smtg') ? 'Something' : 'Nothing');
  7. function foo() { }
  8. var oldName = foo.name;
  9. foo.name = "bar";
  10. console.log([oldName, foo.name])
  11. var name = "The Window";
  12. var object = {
  13. name : "My Object",
  14. getNameFunc : function(){
  15. return function(){
  16. return this.name;
  17. };
  18. }
  19. };
  20. console.log(object.getNameFunc()());
  21. var name = "The Window";
  22. var object = {
  23. name : "My Object",
  24. getNameFunc : function(){
  25. var that = this;
  26. return function(){
  27. return that.name;
  28. };
  29. }
  30. };
  31. console.log(object.getNameFunc()());
  32. var User = {
  33. count: 1,
  34. getCount: function() {
  35. return this.count;
  36. }
  37. };
  38. console.log(User.getCount());
  39. var func = User.getCount;
  40. console.log(func());