如何从对象中删除属性?

时间:2016-05-17 16:28:16

标签: javascript

我有这个对象:

  {"wordFormId":"abandon",
   "wordFormIdentity":1,
   "ascii":97,
   "wordId":"abandon",
   "primary":true,
   "posId":2}

如何删除ascii属性?我知道我可以将它设置为null但我认为它仍然会存在。我想做的是彻底删除它。

1 个答案:

答案 0 :(得分:1)

来自this question

# -*- mode: ruby -*-
# vi: set ft=ruby :

$script1 = <<SCRIPT
echo "Run this provisioner first to write a value to requiresreboot.txt... "
start-process  "C:\\...\\vagrant_provisioning_file1.bat" -wait
SCRIPT

$script2 = <<SCRIPT
echo "Run this provisioner second... "
start-process  "C:\\...\\vagrant_provisioning_file2.bat" -wait
SCRIPT

Vagrant.configure(2) do |config|

  # Other vagrant setup.....
  # ........................

  File.new("requiresreboot.txt", "w+");

  # Enable provisioning with a shell script 1. 
  config.vm.provision "shell", inline: $script1 

  file = File.open("requiresreboot.txt", "r")
  contents = file.read
  if contents == "max_rearms_reached"
    print "Cannot extend Windows 7 trial: maximum number of rearms reached."
  elsif contents == "true"
    # trigger reload (reboot to apply changes for Windows trial renewal)
    print "Windows trial renewal is required"
    config.vm.provision :reload  
  elsif contents == "false"
    print "No reload required, continuing with provisioning..."  
  end
  file.close

  # Enable provisioning with a shell script 2. 
  config.vm.provision "shell", inline: $script2

end