2
function reverse_a_number(n)
{
  n = n + "";
  return n.split("").reverse().join("");
}
console.log(reverse_a_number(32243));
H5页面 Camila Waz 2022-09-05 11:58:53
3
function coinFlip() {
 return (Math.floor(Math.random() * 2) == 0) ? 'heads' : 'tails';
}
H5页面 Camila Waz 2022-09-05 11:53:49
430访问人次
Camila Waz 2022-09-05 12:12:53
1
window.navigator.userAgent
H5页面 Camila Waz 2022-09-05 11:45:55
3
 function sleep(milliseconds) {
    return new Promise(resolve => setTimeout(resolve, milliseconds));
 }
 async function fun() {
    document.write('Hello World');
    for (let i = 1; i <=10 ; i++) {        
       await sleep(2000);
       document.write( i + " " + "Welcome to the javaTpoint.com" + " " + "</br>");
    }
 }
 fun();
H5页面 Camila Waz 2022-09-05 08:47:20
8
function downloadCSV(csv, filename) {  
    var csvFile;  
    var downloadLink;  
     
    //define the file type to text/csv  
    csvFile = new Blob([csv], {type: 'text/csv'});  
    downloadLink = document.createElement("a");  
    downloadLink.download = filename;  
    downloadLink.href = window.URL.createObjectURL(csvFile);  
    downloadLink.style.display = "none";  
  
    document.body.appendChild(downloadLink);  
    downloadLink.click();  
}
H5页面 Camila Waz 2022-09-05 08:27:19
3
var hiddenElement = document.createElement('a');  
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);  
hiddenElement.target = '_blank';  

//provide the name for the CSV file to be downloaded  
hiddenElement.download = 'Famous Personalities.csv';  
hiddenElement.click(); 
H5页面 Camila Waz 2022-09-05 08:26:25
34
const heart_box = document.getElementById('heart')
// 创建标签
let element = document.createElement('div')
    element.id = `heart_${keyName}`
    element.style.cssText = styles.container
    heart_box.appendChild(element)

// 移除标签
setTimeout(function(){
  const heart_element = document.getElementById(`heart_${keyName}`)
  heart_box.removeChild(heart_element)
  const heart_style = document.getElementById(`heart_id_${keyName}`)
  document.head.removeChild(heart_style)
}, 3000)
H5页面 Camila Waz 2022-09-02 19:01:05
80
  function animate(options) {
    var start = performance.now();
    requestAnimationFrame(function animate(time) {
      // timeFraction от 0 до 1
      var timeFraction = (time - start) / options.duration;
      if (timeFraction > 1) timeFraction = 1;

      // текущее состояние анимации
      var progress = options.timing(timeFraction)
      
      options.draw(progress);

      if (timeFraction < 1) {
        requestAnimationFrame(animate);
      }
    });
  }
H5页面 Camila Waz 2022-03-07 13:41:42
108
  • readAsArrayBuffer(blob)– 以二进制格式读取数据ArrayBuffer。
  • readAsText(blob, [encoding])– 以给定编码的文本字符串形式读取数据(utf-8默认情况下)。
  • readAsDataURL(blob)– 读取二进制数据并将其编码为 base64 数据 url。
  • abort()– 取消操作。
  • 更多方法:https://javascript.info/file
H5页面 Camila Waz 2022-03-07 10:46:42
39
<form id="formElem">
  <input type="text" name="name" value="John">
  <input type="text" name="surname" value="Smith">
  <input type="submit">
</form>

<script>
  formElem.onsubmit = async (e) => {
    e.preventDefault();

    let response = await fetch('/article/formdata/post/user', {
      method: 'POST',
      body: new FormData(formElem)
    });

    let result = await response.json();

    alert(result.message);
  };
</script>
H5页面 Camila Waz 2022-03-07 09:56:00