Skip to content

Instantly share code, notes, and snippets.

View ToshihiroGoto's full-sized avatar

Toshihiro Goto ToshihiroGoto

View GitHub Profile
import Foundation
extension String {
func numberOfLines(_ maxLine: Int) -> Self {
if maxLine <= 0 { return self }
return self.split(whereSeparator: \.isNewline).prefix(maxLine).joined(separator: "\n")
}
}
(function () {
"use strict";
var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
// TODO: This application has been newly launched. Initialize your application here.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>UITest</title>
<!-- WinJS references -->
<link href="WinJS/css/ui-dark.css" rel="stylesheet" />
<script src="WinJS/js/base.js"></script>
<script src="WinJS/js/ui.js"></script>
(function () {
"use strict";
// WinJS を使えるように設定
var app = WinJS.Application;
// Windows Runtime を使えるように設定
var activation = Windows.ApplicationModel.Activation;
// アプリ起動時に呼び出される
app.onactivated = function (args) {
function p() {
var raw = String.raw.apply(null, arguments)
console.log(`<p>${raw}</p>`)
}
p`test ${ 4*4 } !` // <p>test 16 !</p>
p`test ${ 8*4 } !` // <p>test 32 !</p>
function str(s,...v){
console.log(s)
console.log(v)
console.log(s.raw[0]);
console.log(s.raw[1]);
console.log(s.raw[3]);
}
str`test1: ${1}, test2: ${2} !`
/* 出力結果
var a = 2
var txt = `答え1:${ 1 + 1 }\n答え2:${ a * 2 }`
console.log(txt)
/* 出力結果
答え1:2
答え2:4
*/
var txt1 = "test"
var txt2 = `test`
txt1 == txt2 // true
var txt = `Les sanglots longs
Des violons
 De l'automne
Blessent mon coeur
D'une langueur
 Monotone.`
console.log(txt)
/* 出力結果
function test(a = 1, b = 2, [...c] = [1,2,3]){
console.log(a,b,...c)
}
test() // 1 2 1 2 3
test(5,4,[3,2,1]) // 5 4 3 2 1