使用字面量的形式创建函数有三种方式: 函数声明 函数表达式 匿名函数 1 <!DOCTYPE html> 2 <html lang="zh"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=devic ...
分类:
其他好文 时间:
2019-12-08 19:05:44
阅读次数:
114
函数 可以实现一定功能的一段代码的封装。 注:函数创建过后,在内存堆中以一段字符串文本储存,不执行时不会产生任何作用,就单单是存了一段字符串。 创建函数 1、字面量(推荐) 关键字 标识符 小括号 {函数体} 例: function F65(){ console.log(`我是一个函数F65`); ...
分类:
Web程序 时间:
2019-12-07 16:41:20
阅读次数:
87
㈠函数(function) ⑴函数也是一个对象 ⑵函数中可以封装一些功能(代码),在需要时可以执行这些功能(代码) ⑶函数中可以保存一些代码在需要的时候调用 ⑷使用typeof检查一个函数对象时,会返回function ⑸创建函数的三种方式: ①构造函数 ②函数声明 ③函数表达式 ⑹示例:创建一个函 ...
分类:
编程语言 时间:
2019-12-07 14:30:06
阅读次数:
81
声明式:function fn() { //do something } 函数表达式: let fn = function () { //do something }构造函数: function Person(name,age){ this.name=name this.age=age } let ...
分类:
Web程序 时间:
2019-12-06 13:38:28
阅读次数:
118
你手上一个条件表达式,它根据对象类型的不同而选择不同的行为。将这个条件表达式的每个分支放进一个子类的覆写函数中,然后将原始函数声明为抽象函数。 动机:多态的最根本的好处是:如果你需要根据对象的不同类型而采取不同的行为,多态使你不必编写某些的条件表达式。 正因为有了多态,所以你会发现:“类型吗的swi ...
分类:
其他好文 时间:
2019-12-04 13:34:34
阅读次数:
112
#include <math.h> #include <stdio.h> #include <stdlib.h> // 函数声明 void solve(double a, double b, double c); // 主函数 int main() { double a, b, c; printf( ...
分类:
其他好文 时间:
2019-12-04 01:39:59
阅读次数:
107
#include <math.h>#include <stdio.h>#include <stdlib.h> // 函数声明void solve(double a, double b, double c); // 主函数 int main() { double a, b, c; printf("En ...
分类:
其他好文 时间:
2019-12-03 23:33:53
阅读次数:
106
以往关注比较多的是变量提升,把变量和函数同名时,函数提升的规则不小心给漏掉了,唉,失去一分,今日笔试题 结果如下图所示: 1) 变量声明存在提升,函数声明存在提升,但函数声明比变量声明更置顶 2) 声明过的变量不会重复声明 ...
分类:
其他好文 时间:
2019-12-03 23:23:51
阅读次数:
126
Part1: #include <math.h> #include <stdio.h> #include <stdlib.h> // 函数声明 void solve(double a, double b, double c); // 主函数 int main() { double a, b, c; ...
分类:
其他好文 时间:
2019-12-03 23:04:58
阅读次数:
73
part1: #include <stdio.h>#include <stdlib.h> // 函数声明void solve(double a, double b, double c); // 主函数 int main() { double a, b, c; printf("Enter a, b, ...
分类:
其他好文 时间:
2019-12-02 01:12:31
阅读次数:
103