我如何简单地转换字符串?

时间:2016-01-11 21:51:19

标签: javascript

如何将字符串var a = "123456";转换为数组z = [1,2,3,4,5,6];?我尝试了一切,似乎没有任何工作。谢谢!

3 个答案:

答案 0 :(得分:0)

对Number使用split('')可以使用JavaScript-C:

'123456789'.split('').map(Number)
[1, 2, 3, 4, 5, 6, 7, 8, 9]

答案 1 :(得分:0)

答案 2 :(得分:0)

只需使用String.prototype.split并使用Number转换为Array.prototype.map对象编号。

public boolean isEmulator() {
        return Build.FINGERPRINT.startsWith("generic")
                || Build.FINGERPRINT.startsWith("unknown")
                || Build.MODEL.contains("google_sdk")
                || Build.MODEL.contains("Emulator")
                || Build.MODEL.contains("Android SDK built for x86")
                || Build.MANUFACTURER.contains("Genymotion")
                || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
                || "google_sdk".equals(Build.PRODUCT);
    }

@Override
protected Bundle getLaunchOptions() {
    Bundle opts = new Bundle();
    opts.putBoolean("isEmulator", isEmulator());
    return opts;
}