Security_Study/웹자료
자바 스크립트 문자열과 vbs 스크립트 문자열 비교
Ryansecurity
2017. 1. 19. 06:11
728x90
Code Comparison
JavaScript | VBScript | |||||||||||||||||||||||||||||||||||||||||||||
// This is a comment. /* Multi-line comment. */ | ‘This is a comment. Rem So is this. No multi-line comments. | |||||||||||||||||||||||||||||||||||||||||||||
Variables, Constants, and Arrays | ||||||||||||||||||||||||||||||||||||||||||||||
var x, y var z = 10 No way to force variables to be declared No constants var Vector = new Array(10) var Names = new Array() var Matrix = new Array(4) Matrix[0] = new Array(5) Vector[9] = 1.5 Matrix[1][4] = 2 | Dim x, y Dim z ‘ Can’t assign on same line z = 10 ‘Force all vars to be declared before being used. Option Explicit Const PI = 3.14 Dim Vector(9) ‘ 9 is last slot ‘ Can’t do this – arrays must have upper bound Dim Matrix(3, 4) Vector(9) = 1.5 Matrix(1, 4) = 2 | |||||||||||||||||||||||||||||||||||||||||||||
Output | ||||||||||||||||||||||||||||||||||||||||||||||
str = " there!" document.write("hello" + str) document.writeln("good\nbye") Response.Write(str) ‘Server-side <%= str %> ‘Another way alert("message") // Client-side | str = " there!" document.write "hello" & str document.writeln "good" & vbCr & "bye" Response.Write str ‘Server-side <%= str %> ‘Another way MsgBox "message" ‘Client-side | |||||||||||||||||||||||||||||||||||||||||||||
Functions | ||||||||||||||||||||||||||||||||||||||||||||||
function Add(a, b) { return a + b } Variable are always passed by value. Only objects can be passed by reference. sum = Add(1, 2) | Function Add(ByVal x, ByVal y) Add = x + y End Function Sub Add2(ByVal x, ByVal y, ByRef ans) ans = x + y End Sub sum = Add(1, 2) Add2 1, 2, sum ‘No () for Sub params Call Add2(1, 2, sum) ‘Alternate call | |||||||||||||||||||||||||||||||||||||||||||||
Decisions | ||||||||||||||||||||||||||||||||||||||||||||||
if (score == 100) alert("Great!") if (a == 1 || a == 5) { vector[a] = b c = 1 } else if (a == 2) b-- else b *= 2 switch(x) { case 1: str = str + "end" break case 2: case 3: y = y * y * y break default: z = z / 2 } | If score = 100 Then _ MsgBox "Great!" If a = 1 Or a = 5 Then vector(a) = b c = 1 ElseIf a = 2 Then b = b - 1 Else b = b * 2 End If Select Case x Case 1 str = str & "end" Case 2, 3 y = y ^ 3 Case 4 To 10 ‘4 <= x <= 10 Case Is >= 25 ‘x >= 25 Case Else ‘Default z = z \ 2 End Select | |||||||||||||||||||||||||||||||||||||||||||||
Loops | ||||||||||||||||||||||||||||||||||||||||||||||
for (i = 1; i <= 5; i++) document.writeln(i) for (c = 2; c <= 10; c += 2) a += c for (var index in myArray) document.write(myArray[index]) while (a < 10) a++ do a++; while (a < 10) | For i = 1 To 5 document.writeln i Next For c = 2 To 10 Step 2 a = a + c Next Dim element For Each element in myArray document.write element Next Do While a < 10 Do Until a = 10 a = a + 1 a = a + 1 Loop Loop Do Do a = a + 1 a = a + 1 Loop While a < 10 Loop Until a = 10 | |||||||||||||||||||||||||||||||||||||||||||||
Arithmetic Operators | ||||||||||||||||||||||||||||||||||||||||||||||
+ - * / % (mod) | + - * / \ (integer division) Mod ^ (raising to a power) | |||||||||||||||||||||||||||||||||||||||||||||
Relational Operators | ||||||||||||||||||||||||||||||||||||||||||||||
< <= > >= == != | < <= > >= = <> | |||||||||||||||||||||||||||||||||||||||||||||
Logic Operators | ||||||||||||||||||||||||||||||||||||||||||||||
&& || ! | And Not Or Xor Eqv (Equivalent) Imp | |||||||||||||||||||||||||||||||||||||||||||||
Bitwise Operators | ||||||||||||||||||||||||||||||||||||||||||||||
& ~ | ^ << >> | And Not Or Xor (no shift left/right) | |||||||||||||||||||||||||||||||||||||||||||||
Strings | ||||||||||||||||||||||||||||||||||||||||||||||
var x x = "HU" x = x + " is great!" | Dim x x = "HU" x = x & " is great!" | |||||||||||||||||||||||||||||||||||||||||||||
VBScript String Functions | ||||||||||||||||||||||||||||||||||||||||||||||
|
728x90