1.函数类型

  1. // 常用函数类型
  2. // 1命名函数
  3. function Num(a,b){
  4. return a + b ;
  5. };
  6. console.log(Num(3,7));
  7. // 2匿名函数
  8. // 赋值调用
  9. let a = function (str){
  10. return'Hello' + str;
  11. };
  12. console.log(a('-Word'));
  13. // 立即调用IIFE
  14. console.log(
  15. (function (str){
  16. return'这是一个匿名函数' + str;
  17. })('使用的是立即调用方法')
  18. );
  19. // 3箭头函数
  20. b = (c,f) =>{
  21. console.log(3+2);
  22. }
  23. b();
  24. let x = cf =>'Are-you' + cf;
  25. console.log(x('-OK?'));

2数据类型

  1. // 2常用数据类型
  2. // 2-1数字类型 number
  3. console.log(typeof 999,typeof 666);
  4. //2-2字符串类型 string
  5. console.log(typeof'Orange');
  6. // 2-3 布尔类型 boolean
  7. console.log(typeof true,typeof false);
  8. // 2-4 未定义 undefined
  9. console.log(typeof undefined);
  10. //2-5空值 null
  11. console.log(null);
  12. // 2-6 数组 Array
  13. const arr = [996,007,955];
  14. console.log(arr);
  15. //返回 ture 就验证这是一个数组
  16. console.log(Array.isArray(arr));
  17. // 2-6 对象 object
  18. let obj = {
  19. id: 1,
  20. userName: '马化腾',
  21. arr: [1,2,3],
  22. 'myQQ': '1684302917',
  23. };
  24. console.log(obj);
  25. console.log(arr);
  26. console.log(obj['myQQ']);
  27. // 2-6 函数 function
  28. // 当值,闭包
  29. function a1() {
  30. let b1 =2;
  31. return function() {
  32. return b1++;
  33. };
  34. }
  35. console.log(a1());
  36. const g = a1();
  37. console.log(g());
  38. console.log(g());
  39. console.log(g());
  40. // 当对象,添加属性和方法
  41. // 属性
  42. let a2 = function(){};
  43. a2.myName = '马化腾';
  44. console.log(a2.myName);
  45. // 方法
  46. a2.youName = function(){
  47. console.log(this.myName);
  48. };
  49. a2.youName();

展示

展示

更多相关文章

  1. Base64编解码Android和ios的例子,补充JNI中的例子
  2. Android(安卓)GridView的使用方法
  3. android handler.removeCallbacksAndMessages(null)的使用
  4. PHP如何通过date() 函数格式化显示时间
  5. 深入聊一聊JS中new的原理与实现
  6. 深入聊一聊JS中new的原理与实现
  7. Base64编解码Android和ios的例子,补充JNI中的例子
  8. Android(安卓)Camera调用流程
  9. Android中如何查看so崩溃的log

随机推荐

  1. android 笔记-scrollview滑动阴影取消
  2. Android摄像头相关问题记录
  3. android自动获取短信验证码
  4. 旋转对话框
  5. 【Android】Android中AlertDialog对话框
  6. Android7.0中文文档(API) -- EdgeEffect
  7. Android(六): What Android Is
  8. 清除app数据等同于设置中的清除数据
  9. Android 弹球游戏
  10. 单选按钮(RadioButton)和复选框(CheckBox)的