如何将字符串var a = "123456";
转换为数组z = [1,2,3,4,5,6];
?我尝试了一切,似乎没有任何工作。谢谢!
答案 0 :(得分:0)
对Number使用split('')可以使用JavaScript-C:
'123456789'.split('').map(Number)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
答案 1 :(得分:0)
var z = "123456".split();
请参阅javascript文档:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split
答案 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;
}