無關鍵字賦值、var宣告、let宣告最大的差別在於生存區域的不同。
無關鍵字賦值 這意味著全域變數的宣告,當然你在全域範圍使用var/let宣告也是全域的。只是無關鍵字可能引發意外的情況,像是你預期變數應該是函數區域的:
function printG(){
g = 1
console.log(`printG: `, g)
}
function wrap(value){ | |
switch(typeof value){ | |
case 'number': | |
return new Number(value) | |
case 'string': | |
return new String(value) | |
case 'boolean': | |
return new Boolean(value) | |
case 'symbol': |
call.exec = true; | |
call.toc = true; | |
call(callme, 1); | |
function callme(i) { | |
if (i < 0) return i; | |
console.log(i); |
無關鍵字賦值、var宣告、let宣告最大的差別在於生存區域的不同。
無關鍵字賦值 這意味著全域變數的宣告,當然你在全域範圍使用var/let宣告也是全域的。只是無關鍵字可能引發意外的情況,像是你預期變數應該是函數區域的:
function printG(){
g = 1
console.log(`printG: `, g)
}
;; -*- mode: emacs-lisp -*- | |
;; This file is loaded by Spacemacs at startup. | |
;; It must be stored in your home directory. | |
(defun dotspacemacs/layers () | |
"Configuration Layers declaration. | |
You should not put any user code in this function besides modifying the variable | |
values." | |
(setq-default | |
;; Base distribution to use. This is a layer contained in the directory |
let block_keeper = document.querySelector("div.bg\\:white:nth-child(1) > div:nth-child(1) > div:nth-child(1)"); | |
let video_region = block_keeper.firstChild; | |
block_keeper.style.height = "400px"; | |
video_region.style.width = "700px"; | |
video_region.style.position = "fixed"; | |
video_region.style.zIndex = 1; |
class Repeatable{ | |
static RUN = 0; | |
static BREAK = -1; | |
static CONTINUE = 1; | |
constructor(env = {}){ | |
this.i = 0; | |
this.env = env; | |
this._env = {...env}; | |
this.status = Repeatable.RUN; |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const webpack = require('webpack'); | |
const path = require('path'); | |
const config = { | |
mode: 'development', | |
entry:{ | |
index: "./src/index.js", | |
}, | |
output:{ |
function on_back_click() | |
local str = tostring(input_number) | |
str = str:sub(0, str:len()-1) | |
input_number = tonumber(str) | |
if not input_number then input_number = 0 end | |
end |
// about atexit and on_exit: https://www.gnu.org/software/libc/manual/html_node/Cleanups-on-Exit.html | |
#include <stdio.h> | |
void byebye(); | |
void seeyouagain(); | |
int main() | |
{ | |
void *p = NULL; | |
atexit(byebye); | |
on_exit(seeyouagain, p); |
class Proxy: | |
__handler = None | |
def __init__(self, handler:object): | |
self.__handler = handler | |
@classmethod | |
def Cproxy(clz, opt:str, default_handler = None): | |
def _handler(self, *args, **kwargs): | |
handler = getattr(self.__handler, opt, default_handler if default_handler else clz.__defaultOpt) | |
return handler(*args, **kwargs) | |
return _handler |