功能范围外的可变范围

时间:2016-01-28 07:14:47

标签: javascript php function variables range

我发现了一个类似的主题,用户在变量名称之前回复了“窗口”名称。但它似乎对我不起作用。 有人可以帮我理解为什么在console.log()中打印的window.data_from_ajax; $.get('java_test.php', function(data) { window.data_from_ajax = data; alert(data); }); console.log('data_from_ajax='+window.data_from_ajax); 未定义?

PHP

You can use image loading libraries like Universal Image Loader, Fresco.
1) https://github.com/nostra13/Android-Universal-Image-Loader
2) https://github.com/facebook/fresco
3) https://guides.codepath.com/android/Displaying-Images-with-the-Fresco-Library

的Javascript

package main

import (
    "fmt"
    "sync"
    "time"
)

var mu sync.Mutex

func main() {
    cache := make(map[int]int, 1000000)
    start := time.Now()

    for i := 0; i < 1000000; i++ {
        mu.Lock()
        if _, ok := cache[i]; ok == false {
            cache[i] = i
        }
        mu.Unlock()
    }

    end := time.Since(start)
    fmt.Println(end)

    var sum int64
    for _, v := range cache {
        sum += int64(v)
    }

    fmt.Println(sum)
}

0 个答案:

没有答案