AMPscript | SSJS | |
---|---|---|
Use case | ・ Emails | ・ CloudPage ・ SSJS makes execution of emails slow and hence should only be used when there are no functions to support in AMPscript |
Declare code block | %%[ AMPscript goes here ]%% |
<script runat=server> SSJS goes here </script> |
Write value | oututline(v(@variable)) | Write(ContentBlockByKey('1a1a111a-0111-1111-a111-a111a111111a')) |
IF statement | SET @a = 1 IF @a == 1 THEN SET @b = "true" ELSE SET @b = "false" ENDIF |
var a = 1; if (a == 1) { Write ("true"); ) else ( Write("false"); } |
For loop | FOR @a = 1 to 10 do outputline(v(@a) NEXT @a |
for(var a = 0; a <= 10; a++) { Write (a+ " } |